package com.fw.render;

import java.io.IOException;
import java.io.PrintWriter;

import com.fw.exception.RenderException;

public class JavascriptRender extends Render {

	private static final long serialVersionUID = 5357404401456937608L;
	private static final String contentType = "text/javascript;charset=" + getEncoding();
	private String jsText;

	public JavascriptRender(String jsText) {
		this.jsText = jsText;
	}

	public void render() {
		PrintWriter writer = null;
		try {
			response.setContentType(contentType);
			writer = response.getWriter();
			writer.write(jsText);
			writer.flush();
		} catch (IOException e) {
			throw new RenderException(e);
		} finally {
			if (writer != null) {
				writer.close();
			}
		}
	}
}
